Electronic Piano
In this project, we build a piano by using four push buttons which when clicked, give different frequencies of sound to create a musical effect.
Circuit

Components
- 1 Smowboard Think Mini
- 1 speaker
- 1 10uF capacitor
- 1 100k ohm resistor
- 1 BC547 transistor
- 4 push buttons
- 7 male-to-female jumper wires
- 5 male-to-male jumper wires
In this circuit, we connect a transistor on the breadboard. We connect the 100k ohm resistor across the base-collector junction of the transistor. We connect the negative terminal of the capacitor to the base of the transistor and the positive terminal of the capacitor to the pin number 21 of Smowboard. We connect one terminal of the speaker to Vin pin of the Smowboard while its other terminal is connected to the collector of transistor. The emiiter of the transisitor is grounded by connecting it to the ground of Smowboard. The four push buttons are grounded by connecting one of their terminal to the ground of the Smowboard. We connect the other terminals of the four push buttons to the pin number 13, 4, 5, 15 of Smowboard respectively.
The speaker is connected to the Smowboard using capacitor and transistor. The Smowboard controls the frequency of the sound. There are four push buttons. The Smowboard gives out sound of different frequencies respective to the push button clicked. Thus, when different buttons are clicked different frequency sond is obtained.
Flow

[{"id":"3d0219a5.c61bf6","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"97221d5c.1a185","type":"smow_pin/on button click","z":"3d0219a5.c61bf6","config_props":{"name":"","pin_number":"13","connection_type":"0","auto_pull_up_down":"true"},"outputProps":{},"dependency_set":{},"x":190,"y":140,"wires":[["6fca6621.7521c8"]]},{"id":"6fca6621.7521c8","type":"smow_pulse/sound","z":"3d0219a5.c61bf6","config_props":{"name":"","config":"99a277dd.92a538","on_off":"1","frequency":"750"},"outputProps":{},"dependency_set":{"switch_on":true},"x":460,"y":140,"wires":[["c4f54b8e.e637a8"]]},{"id":"7f7944b6.6c6dbc","type":"smow_pin/on button click","z":"3d0219a5.c61bf6","config_props":{"name":"","pin_number":"4","connection_type":"0","auto_pull_up_down":"true"},"outputProps":{},"dependency_set":{},"x":190,"y":240,"wires":[["ff2c0d0d.9d857"]]},{"id":"ff2c0d0d.9d857","type":"smow_pulse/sound","z":"3d0219a5.c61bf6","config_props":{"name":"","config":"99a277dd.92a538","on_off":"1","frequency":"650"},"outputProps":{},"dependency_set":{"switch_on":true},"x":460,"y":240,"wires":[["c4f54b8e.e637a8"]]},{"id":"efb39525.3f2998","type":"smow_pin/on button click","z":"3d0219a5.c61bf6","config_props":{"name":"","pin_number":"5","connection_type":"0","auto_pull_up_down":"true"},"outputProps":{},"dependency_set":{},"x":190,"y":340,"wires":[["be3e07a7.4c9ab8"]]},{"id":"be3e07a7.4c9ab8","type":"smow_pulse/sound","z":"3d0219a5.c61bf6","config_props":{"name":"","config":"99a277dd.92a538","on_off":"1","frequency":"550"},"outputProps":{},"dependency_set":{"switch_on":true},"x":460,"y":340,"wires":[["c4f54b8e.e637a8"]]},{"id":"f8822bc.fba97d8","type":"smow_pin/on button click","z":"3d0219a5.c61bf6","config_props":{"name":"","pin_number":"15","connection_type":"0","auto_pull_up_down":"true"},"outputProps":{},"dependency_set":{},"x":190,"y":460,"wires":[["5be5fdd5.4b1a24"]]},{"id":"5be5fdd5.4b1a24","type":"smow_pulse/sound","z":"3d0219a5.c61bf6","config_props":{"name":"","config":"99a277dd.92a538","on_off":"1","frequency":"450"},"outputProps":{},"dependency_set":{"switch_on":true},"x":460,"y":460,"wires":[["c4f54b8e.e637a8"]]},{"id":"c4f54b8e.e637a8","type":"common/delay","z":"3d0219a5.c61bf6","config_props":{"name":"","period":"0.35"},"outputProps":{},"dependency_set":{},"x":710,"y":300,"wires":[["583ccb08.832c64"]]},{"id":"583ccb08.832c64","type":"smow_pulse/sound","z":"3d0219a5.c61bf6","config_props":{"name":"","config":"99a277dd.92a538","on_off":"0","frequency":"650"},"outputProps":{},"dependency_set":{"switch_on":false},"x":920,"y":300,"wires":[[]]},{"id":"99a277dd.92a538","type":"smow_pulse/analog write config","z":"","config_props":{"name":"","pin":"21","duty_resolution":"11","timer_num":"0","led_channel":"0","clk_config":"0","speed_mode":"0"},"outputProps":{},"dependency_set":{}}]
To import this code to the Studio, copy it and paste it into the import nodes dialog box in the import section.
Lets understand the code,
- The flow starts with an
on button clicknode. This node gets triggered when a button is clicked. - Double click on the node to change its properties.
- We set the 'pin no.' property as 13 as we have connected the first push button to the pin number 13 of Smowboard.
- We connect a
soundnode to give an audio ouput when a button is clicked. Configure thesoundnode by clicking on the pencil icon on the 'Output' property of the node. Set the 'Output pin' to 21 as we have connected the speaker output to pin number 21 of Smowboard. - We then click on
Addanddoneto complete the configuration. - We set the 'switch' property of the node to 'Turn ON' and the 'tone' to 750 Hz.
- Now, we copy this code by selecting it and paste it below three times for the remaining three push buttons.
- We set the 'pin no.' property of the three
on button clicknodes as 4, 5, 15 respectively as we have connected the push buttons to these pins of the Smowboard. - We set the tone of the
soundnodes as 650Hz, 550Hz, 450Hz respectively. - We now add a
delaynode to add a delay of 0.35 seconds before the next node,soundruns. - Whenever we click a button, the sound will remain for 0.35 seconds due to this delay.
- The
delaynode is connected to all the foursoundnodes as shown in the flow. - We now connect a
soundnode to thedelaynode. We set the 'switch` property of this node to 'Turn OFF' to turn OFF the speaker. - Now, we upload the code to the Smowboard using the
uploadbutton on the Studio. - We can see that whenever we click different buttons, we get different sounds due to different frequencies set. The sound remains for 0.35 seconds.
Output

Learn Coding and Electronics easily using Smowcode.